#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<cstring>
#include<unordered_map>
#include<unordered_set>
#define int long long 
#define x first 
#define y second 
using namespace std;
const int N = 1e5 + 10;

void solve()
{
     int a; cin >> a;
/*      for(int i = 1; i <= 1e9; i++)
     {
         int t = a ^ i;
         if(i ^ t == a && t >= 1 && t <= 1e9) 
         {
            cout << i << " " << t << endl;
            return; 
         }
     } */
     if(a == 1) cout << 2 << " " << 3 << endl;
     else if(a == 1e9) cout << 999999999 << " " << 1023 << endl;
     else cout << 1 << " " << (1 ^ a) << endl; 

}
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int t ;
    cin >> t;
    while(t--) solve();
    return 0;
}